import PropTypes from 'prop-types'
import classNames from 'classnames'

const Welcome = (props) => {
  // 动态组合class类名
  const classes = classNames('abc', 'def', ['xyz', { zzz: true, yyy: false }])
  return (
    <>
      <div>
        <h1 className={classes}>welcome组件-{props.name}</h1>
        <button
          onClick={() => {
            props.send({ a: 1 })
          }}
        >
          button
        </button>
        {props.children}
      </div>
    </>
  )
}

// props类型校验和是否必传
Welcome.propTypes = {
  name: PropTypes.string.isRequired,
  send: PropTypes.func,
  children: PropTypes.any,
}

// 设置默认值
Welcome.defaultProps = {
  name: '匿名',
}

export default Welcome
